package com.ruoyi.discuss.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.discuss.mapper.BiglikeMapper;
import com.ruoyi.discuss.domain.Biglike;
import com.ruoyi.discuss.service.IBiglikeService;

/**
 * 点赞Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-14
 */
@Service
public class BiglikeServiceImpl implements IBiglikeService
{
    @Autowired
    private BiglikeMapper biglikeMapper;

    /**
     * 查询点赞
     *
     * @param likeid 点赞主键
     * @return 点赞
     */
    @Override
    public Biglike selectBiglikeByLikeid(Long likeid)
    {
        return biglikeMapper.selectBiglikeByLikeid(likeid);
    }

    /**
     * 查询点赞列表
     *
     * @param biglike 点赞
     * @return 点赞
     */
    @Override
    public List<Biglike> selectBiglikeList(Biglike biglike)
    {
        return biglikeMapper.selectBiglikeList(biglike);
    }

    /**
     * 新增点赞
     *
     * @param biglike 点赞
     * @return 结果
     */
    @Override
    public int insertBiglike(Biglike biglike)
    {
        Long userId = SecurityUtils.getUserId();
        biglike.setUserid(userId);
//        System.err.println("biglike = " + biglike);
        return biglikeMapper.insertBiglike(biglike);
    }

    /**
     * 修改点赞
     *
     * @param biglike 点赞
     * @return 结果
     */
    @Override
    public int updateBiglike(Biglike biglike)
    {
        return biglikeMapper.updateBiglike(biglike);
    }

    /**
     * 批量删除点赞
     *
     * @param likeids 需要删除的点赞主键
     * @return 结果
     */
    @Override
    public int deleteBiglikeByLikeids(Long[] likeids)
    {
        return biglikeMapper.deleteBiglikeByLikeids(likeids);
    }

    /**
     * 删除点赞信息
     *
     * @param likeid 点赞主键
     * @return 结果
     */
    @Override
    public int deleteBiglikeByLikeid(Long likeid)
    {
        return biglikeMapper.deleteBiglikeByLikeid(likeid);
    }
}
